package com.k2data.k2app.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Data
@Table(name = "sys_menu")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SysMenu implements Serializable {

    @Id
    @GeneratedValue(generator = "JDBC")
    private Long id;
    private Long parentId;
    private String name;
    private Long sort;
    private String href;
    private String target;
    private String icon;
    private Integer isShow = 1;
    private String permission;
    @JsonIgnore
    private String createBy;
    @JsonIgnore
    private String createDate;
    @JsonIgnore
    private String updateBy;
    @JsonIgnore
    private LocalDateTime updateDate;
    private String remarks;
    @JsonIgnore
    private Integer isDelete;

    @Transient
    private List<SysMenu> children = new ArrayList<>();

    @Override
    public String toString() {
        return "SysMenu{" +
                "id=" + id +
                ", parentId=" + parentId +
                ", name='" + name + '\'' +
                ", sort=" + sort +
                ", href='" + href + '\'' +
                ", target='" + target + '\'' +
                ", icon='" + icon + '\'' +
                ", isShow=" + isShow +
                ", permission='" + permission + '\'' +
                ", createBy='" + createBy + '\'' +
                ", createDate=" + createDate +
                ", updateBy='" + updateBy + '\'' +
                ", updateDate=" + updateDate +
                ", remarks='" + remarks + '\'' +
                ", isDelete=" + isDelete +
                ", children=" + children +
                '}';
    }
}